"use strict";
let a;
let b;
let c;
a = 'hello';
b = -99;
c = true;
console.log(a, b, c);
function count(x, y) {
    return x + y;
}
let result = count(1, 2);
console.log(result);
let str1; // TS官方推荐的方法
str1 = 'hello';
// str1 = new String('hello') // 不能将类型“String”分配给类型“string”。  “string”是基元，但“String”是包装器对象。
let str2;
str2 = 'hello';
str2 = new String('hello');
class Package {
    // 构造方法
    constructor(weight) {
        this.weight = weight;
    }
    // 具体方法
    printPackage() {
        console.log(`包裹重量为：${this.weight}kg, 运费为：${this.calculate()}元`);
    }
}
class StandardPackage extends Package {
    constructor(weight, unitPrice) {
        super(weight);
        this.unitPrice = unitPrice;
    }
    calculate() {
        return this.weight * this.unitPrice;
    }
}
const s1 = new StandardPackage(10, 5);
s1.printPackage();
class ExpressPackage extends Package {
    constructor(weight, unitPrice, additional) {
        super(weight);
        this.unitPrice = unitPrice;
        this.additional = additional;
    }
    calculate() {
        if (this.weight > 10)
            return 10 * this.unitPrice + (this.weight - 10) * this.additional;
        return this.weight * this.unitPrice;
    }
}
const s2 = new ExpressPackage(13, 8, 2);
s2.printPackage();
class Person {
    constructor(name, age) {
        this.name = name;
        this.age = age;
    }
    speak(n) {
        for (let i = 0; i < n; i++) {
            console.log(`我是学生，我叫: ${this.name}, 今年${this.age}岁`);
        }
    }
}
const p1 = new Person('Tom', 18);
p1.speak(4);
function logData(data) {
    console.log(data);
}
logData(1);
logData('abc');
let c1 = {
    name: 'Andy',
    age: 12,
    extraInfo: 'good'
};
let c2 = {
    name: 'Andy',
    age: 12,
    extraInfo: 180
};
